<?php
defined('BASEPATH') OR exit('No direct script access allowed');


use QCloud_WeApp_SDK\Mysql\Mysql as DB;


class OrderUpdate extends CI_Controller
{
    public function index()
    {
        $ordernum = $_POST['ordernum'];
        $userid = $_POST['userid'];
        $zt = $_POST['zt'];

        $rows = DB::update('cc_order',['zt' => $zt], ['userid' => $userid, 'ordernum' => $ordernum]);
        if($zt!=8&&$rows){
            $total_fee = $_POST['total_fee'];
            $userid = $_POST['userid'];
            $insert_time = date("Y-m-d H:i:s", intval(time()));
            $rows = DB::insert('cc_pay_sucess', ['total_fee' => $total_fee, 'ordernum' => $ordernum,'userid' => $userid,'paytime' => $insert_time]);
        }

        if (!empty($rows)) {
            $this->json([
                'code' => 0,
                'data' => $rows
            ]);
        } else {
            $this->json([
                'code' => -1,
                'error' => $rows['error']
            ]);
        }
    }
}
